package com.le.component;

import javax.swing.*;
import java.awt.*;

/**
 * @author 乐旋
 * @version 1.0
 **/

/*使用示例：
String path = "images//libraryle.jpg(这里指定文件路径)" images为根目录下的子目录
BackGroundPanel backGroundPanel = new BackGroundPanel(path)
* */

public class BackGroundPanel extends JPanel {
    //声明图片
    private Image backImage;

    public BackGroundPanel(Image backImage) {
        this.backImage = backImage;
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.drawImage(backImage, 0, 0, this.getWidth(), this.getHeight(), null);
    }
}
